<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>用户协议&隐私政策</title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport" />
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        div {
            border: none;
            width: 100vw;
            height: 100vh;
            box-sizing: border-box;
            padding: 20px;
            background-color: #FFFFFF;
            color: #333333;
            font-size: 14px;
            line-height: 20px;
        }
    </style>
</head>

<body>
    <div id="div"></div>
</body>

</html>
<script type="text/javascript">

    const url = 'https://app.uqrixayli.com/api/app/other/setting'
    function parseQueryString(url) {
        const urlKey = url.split('?')[1]
        const objKeyValue = {}
        if (!urlKey) return objKeyValue
        const urlObj = urlKey.split('&')
        for (let i = 0; i < urlObj.length; i++) {
            objKeyValue[urlObj[i].split('=')[0]] = decodeURI(urlObj[i].split('=')[1])
        }
        return objKeyValue
    }
    const urlParams = parseQueryString(window.location.href)
    console.log(urlParams, 'urlParamsurlParamsurlParams')
    /* url转字符串 */
    const httpRequest = new XMLHttpRequest() //第一步：创建需要的对象
    httpRequest.open('GET', url,
        true) //第二步：打开连接/***发送json格式文件必须设置请求头 ；如下 - */
    httpRequest.setRequestHeader('Content-type',
        'application/json') //设置请求头 注：post方式必须设置请求头（在建立连接后设置请求头
    httpRequest.send(JSON.stringify({
        // type: urlParams.type || 0
    })) //发送请求 将json写入send中
    // 获取数据后的处理程序
    httpRequest.onreadystatechange = function () { //请求后的回调接口，可将请求成功后要执行的程序写在其中
        console.log(httpRequest)
        if (httpRequest.readyState == 4 && httpRequest.status == 200) { //验证请求是否发送成功
            const res = JSON.parse(httpRequest.responseText) //获取到服务端返回的数据
            if (res.code == 0) {
                let content = res.data.privacyPolicy
                if (urlParams.type == 'userAgreement') { content = res.data.userAgreement }
                document.getElementById('div').innerText = content.replace(/<[^>]+>|&[^>]+;/g, "")
            }
        }
    }
</script>